import { Message, UserMessage } from '@renderer/types'
import { defineStore } from 'pinia'

interface userMessageStoreInterface {
  selectUserId: string
  userMessage: UserMessage | null
}

export const useUserMessageList = defineStore('userMessage', {
  state: (): userMessageStoreInterface => {
    return {
      selectUserId: '',
      userMessage: null
    }
  },
  getters: {
    getUserMessage: (state) => state.userMessage,
    getGetSelectUserId: (state) => state.selectUserId
  },
  actions: {
    setUserMessage(value: UserMessage) {
      this.userMessage = value
    },
    setMessageListItem(value: Message) {
      this.userMessage?.messages.push(value)
    },
    setSelectUserId(value: string) {
      this.selectUserId = value
    }
  }
})
